//
//  AppDelegate.m
//  MQ
//
//  Created by lanou on 15/10/26.
//  Copyright © 2015年 徐永祥. All rights reserved.
//

#import "AppDelegate.h"
#import "MQMusicMainViewController.h"
#import "MQReadMainViewController.h"
#import "MQPictureMainViewController.h"
#import "MQVideoMainViewController.h"
#import "UMSocial.h"
#import <AVFoundation/AVFoundation.h>
#import "PKPlayerManger.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    //状态栏改为白色
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    //获取当前屏幕亮度
    NSUserDefaults *defa = [NSUserDefaults standardUserDefaults];
    CGFloat light = [UIScreen mainScreen].brightness;
    [defa setFloat:light forKey:@"brightness"];
    //友盟
    [UMSocialData setAppKey:@"561b79fde0f55ac7c00016bf"];
    //阅读
   MQReadMainViewController *readVC = [[MQReadMainViewController alloc]init];
    UINavigationController *navigationRead = [[UINavigationController alloc]initWithRootViewController:readVC];
    //视频
    MQVideoMainViewController *videoVC = [[MQVideoMainViewController alloc]init];
    UINavigationController *navigationVideo = [[UINavigationController alloc]initWithRootViewController:videoVC];
    //图片
    MQPictureMainViewController *pictureVC = [[MQPictureMainViewController alloc]init];
    UINavigationController *navigationPicture = [[UINavigationController alloc]initWithRootViewController:pictureVC];
    // 音乐
    MQMusicMainViewController *musicVC = [[MQMusicMainViewController alloc]init];
    UINavigationController *navigationMusic = [[UINavigationController alloc]initWithRootViewController:musicVC];
    
    
    NSArray *naviArr = [NSArray arrayWithObjects:navigationRead,navigationVideo,navigationPicture,navigationMusic, nil];
    UITabBarController *tabBar = [[UITabBarController alloc]init];
    [tabBar setViewControllers:naviArr animated:YES];
#pragma mark- tabBarItem
    //标题
    navigationRead.tabBarItem.title = @"阅读";
    navigationRead.tabBarItem.image = [UIImage imageNamed:@"yuedu"];
    
    
    navigationMusic.tabBarItem.title = @"音乐";
    navigationMusic.tabBarItem.image = [UIImage imageNamed:@"yinyue"];
    
    navigationPicture.tabBarItem.title = @"图片";
    navigationPicture.tabBarItem.image = [UIImage imageNamed:@"tupian"];
    
    navigationVideo.tabBarItem.title = @"视频";
    navigationVideo.tabBarItem.image = [UIImage imageNamed:@"shipin"];
    //图片
    
    self.window.rootViewController = tabBar;
    [self.window makeKeyAndVisible];

    
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
       //设置屏幕亮度为第一次进来的亮度
    NSUserDefaults *defa = [NSUserDefaults standardUserDefaults];
    CGFloat light = [defa floatForKey:@"brightness" ];
    [[UIScreen mainScreen] setBrightness:light];
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
